<?php 
 
 require '../db.func.php';
 require 'head.php';

 if(!empty($_POST['name'])){
 		$name=$_POST['name'];
 		$pass=$_POST['pass'];
 		$prefix=getprefix();
 	if($_GET['action']=='reg'){
 		$email=$_POST['email'];
 		
 		$created_at=date('Y-m-d H:i:s ');
 		$sql="INSERT INTO {$prefix}user(username,password,email,created_at) VALUES('$name','$pass','$email','$created_at')";

 		 execute($sql);
 		 setinfo('注册成功');

 	}
 	elseif($_GET['action']=='login'){
 		$sql="SELECT id,username FROM {$prefix}user WHERE username='$name' AND password='$pass'";
 		$res=queryone($sql);
 		
 		if($res){
 			 	setsession('shop',['username'=>$name,'id'=>$res['id']]);	
 			 	header('location: index.php');
 			 	 	
 			 	

 		}
 		else{
 			 setinfo('登录失败');

 		}

 		}

 
 }

?>
<div class="body__overlay"></div>
	<!-- Start Offset Wrapper -->
	<div class="offset__wrapper">
		<!-- Start Search Popap -->
		<div class="search__area">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<div class="search__inner">
							<form action="#" method="get">
								<input placeholder="Search here... " type="text">
								<button type="submit"></button>
							</form>
							<div class="search__close__btn">
								<span class="search__close__btn_icon"><i class="zmdi zmdi-close"></i></span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- End Search Popap -->
		<!-- Start Offset MEnu -->
		<div class="offsetmenu">
			<div class="offsetmenu__inner">
				<div class="offsetmenu__close__btn">
					<a href="#"><i class="zmdi zmdi-close"></i></a>
				</div>
				<div class="off__contact">
					<div class="logo">
						<a href="index.html">
							<img src="assets/images/logo/logo.png" alt="logo">
						</a>
					</div>
				</div>
			</div>
		</div>
		<!-- End Offset MEnu -->
		<?php  require 'pan_cart.php' ?>
	</div>
	<!-- End Offset Wrapper -->


	<!-- Start Login Register Area -->
	<div class="htc__login__register bg__white ptb--130">
		<div class="container">
			<div class="row">
				<div class="col-md-6 col-md-offset-3">
					<ul class="login__register__menu" role="tablist">
						<li role="presentation" class="login active"><a href="#login" role="tab" data-toggle="tab">登录</a></li>
						<li role="presentation" class="register"><a href="#register" role="tab" data-toggle="tab">注册</a></li>
					</ul>
				</div>
			</div>
			<!-- Start Login Register Content -->
			<div class="row">
				<div class="col-md-6 col-md-offset-3">
					<div class="htc__login__register__wrap">
						<!-- Start Single Content -->
						<div id="login" role="tabpanel" class="single__tabs__panel tab-pane fade in active">
								<?php  if(hasinfo()) echo getinfo();?>
							<form id="loginform" class="login" method="post" action="login.php?action=login">
								<input type="text" placeholder="User Name*" name="name">
								<input type="password" placeholder="Password*" name="pass">
							</form>

							<div class="htc__login__btn mt--30">
								<a href="javascript: document.getElementById('loginform').submit();">登录</a>
							</div>

						</div>
						<!-- End Single Content -->
						<!-- Start Single Content -->
						<div id="register" role="tabpanel" class="single__tabs__panel tab-pane fade">
							<?php  if(hasinfo()) echo getinfo();?>
							<form id="regform" class="login" method="post" action="login.php?action=reg">
								<input type="text" placeholder="Name*" name="name">
								<input type="email" placeholder="Email*" name="email">
								<input type="password" placeholder="Password*" name="pass">
							</form>

							<div class="htc__login__btn">
								<a href="javascript: document.getElementById('regform').submit();">注册</a>
							</div>

						</div>
						<!-- End Single Content -->
					</div>
				</div>
			</div>
			<!-- End Login Register Content -->
		</div>
	</div>
	<!-- End Login Register Area -->

	<div class="only-banner ptb--10 bg__white">
	</div>

	<?php
		require 'foot.php';
	?>